# -*- coding: utf-8 -*-
# @Author  : 曾诗诗
# @Time    : 2022/5/13 16:43
# @Function:

import sqlite3
import os

# 1. create table and database
dbPath = '../DB/questionnaire.db'

con = sqlite3.connect(dbPath)
cur=con.cursor()

# cur.execute('''create table Expert
#         (Eid varchar primart key not null,
#         Epassword varchar not null,
#         Ename varchar not null);
#         ''')
# cur.execute('''create table Organizer
#         (Oid varchar primart key not null,
#         Opassword varchar not null,
#         Oname varchar not null);''')
# cur.execute('''create table Questionnaire
#         (Eid varchar primart key not null,
#         Question1 varchar not null,
#         Question2 varchar not null,
#         Question3 varchar not null);''')
#
# cur.execute('''
# insert into Organizer(Oid,Opassword,Oname)
# values('191001222','191001222','曾诗诗')
# ''')
# cur.execute('''
#     insert into Organizer(Oid,Opassword,Oname)
#     values('191001223','191001223','刘诗琪')
#     ''')
# cur.execute('''
#         insert into Organizer(Oid,Opassword,Oname)
#         values('191001228','191001228','刘秋岐')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001219','191001219','吴千漉')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001218','191001218','那文蕙')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001118','191001118','王楚熠')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001221','191001221','胡冰越')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001220','191001220','金秀妍')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001213','191001213','朱彤')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001225','191001225','仉一铭')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001209','191001209','赵清波')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001208','191001208','李冠宇')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001210','191001210','王彦朝')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001112','191001112','陈柄言')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001214','191001214','吕瑞霖')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001226','191001226','吕欣桐')
#         ''')
# cur.execute('''
#         insert into Expert(Eid,Epassword,Ename)
#         values('191001226','191001226','吕欣桐')
#         ''')
# sql="select * from Questionnaire"
# results=cur.execute(sql)
# all_results=cur.fetchall()
# for result in all_results:
#     print(result)
con = sqlite3.connect("./questionnaire.db", timeout=10, check_same_thread=False)
cur = con.cursor()
sql = "select * from Questionnaire2"
cur.execute(sql)
results = cur.fetchall()
sums=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
means=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
for result in results:
    for i in range(18):
        # print(result[i+1])
        sums[i]+=result[i+1]
for i in range(18):
    means[i] = sums[i]/14
print(means)
con.commit()
con.close()




